/**
 * 
 */
package com.volatileshooter.entity.bullets;

import com.volatileshooter.entity.Entity;
import com.volatileshooter.entity.EntityController;
import com.volatileshooter.entity.EntityEvent;

/**
 * @author Ahmed
 *
 */
public class BulletController implements EntityController {

	/* (non-Javadoc)
	 * @see com.volatileshooter.entity.EntityController#event(com.volatileshooter.entity.EntityEvent)
	 */
	@Override
	public void event(EntityEvent event) {
		// no event, besides a collision, could affect the bullet

	}

	/* (non-Javadoc)
	 * @see com.volatileshooter.entity.EntityController#update(float, com.volatileshooter.entity.Entity)
	 */
	@Override
	public void update(float time, Entity parent) {
		BulletEntity entity = (BulletEntity)parent;
		entity.setLife(entity.getLife() + (time * entity.getSpeed()));
		float nextX = entity.getPosition().x + (entity.getDirection().x * entity.getSpeed());
		float nextY = entity.getPosition().y + (entity.getDirection().y * entity.getSpeed());
		entity.getPosition().set(nextX, nextY);
	}

}
